package com.intretech.tj.etc;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.intretech.tj.device.Device;
import com.intretech.tj.device.Type;
import lombok.Data;

@Data
public class ETC {
    private int id;

    private State state = State.CLOSE;

    public ETC(int id) {
        this.id = id;
    }

    @JsonCreator
    public ETC(@JsonProperty("id") int id, @JsonProperty("state") int value) {
        this.id = id;
        this.state = State.valueOf(value);
    }

    public Device toDevice() {
        return new Device(id, Type.Gate, "", state.getChinese());
    }
}
